/**
 * 
 */
package net.empego.testwebapp;

import java.io.Serializable;

import javax.inject.Inject;

import net.empego.db.ActionConfigurationDO;
import net.empego.zkcdi.event.ObservesZkEvent;
import net.empego.zkcdi.util.ZkCdiEventHandlerComposer;

import org.zkoss.codemirror.Codemirror;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zul.Div;

/**
 * @author Thomas
 * 
 */
public class CodeEditorComposer extends ZkCdiEventHandlerComposer implements Serializable {

	private static final long serialVersionUID = 7134886362932275459L;

	@Inject
	private Codemirror codemirror;

	@Inject
	private Div testArea;

	@Inject
	private ActionConfigurationDO actionConfiguration;

	public void testActionConfiguration(@ObservesZkEvent("testButton.onClick") final MouseEvent evt) {
		final String content = codemirror.getValue();
		testArea.getChildren().clear();
		Executions.getCurrent().createComponentsDirectly(content, null, testArea, null);

	}

	public void saveActionConfiguration(@ObservesZkEvent("saveButton.onClick") final MouseEvent evt) {
		final String content = actionConfiguration.getContent();
		content.length();
	}

}
